package com.sixth.stock.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sixth.core.entity.User;
import com.sixth.core.vo.R;
import com.sixth.stock.mapper.UserMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/stock/user")
public class UserController {
    @Resource
    UserMapper userMapper;
    @GetMapping ("/getUserListRanges")
    public R<List<User>> getUserListRanges(){
        Page<User> page = new Page<>(1,15);
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",0).eq("del_flag",0).eq("user_type",1).eq("scheduling_flag",0);
        queryWrapper.orderByDesc("RAND()");
        List<User> userList = userMapper.selectList(page,queryWrapper);
        return R.ok(userList);
    }
    //根据科室获取用户列表
    @GetMapping("/getUserListByDeptId/{deptId}")
    public R<List<User>> getUserListByDeptId(@PathVariable("deptId") Long deptId){
        List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("dept_id",deptId).eq("status",0).eq("del_flag",0).eq("user_type",1));
        return R.ok(userList);
    }

}
